﻿Public Class clsProdInfo

    Public Function getProdInfoByStatus(status As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT * FROM sf.b_prod_info WHERE factory_id=? and status = ? "
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", status)
        Return dt
    End Function

    Public Function getProdInfoByProdId(prod_id As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT * FROM sf.b_prod_info WHERE factory_id=? and prod_id = ? "
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", prod_id)
        If IsNothing(dt) Then
            getProdInfoByProdId = New DataTable
        Else
            getProdInfoByProdId = dt
        End If
    End Function

    Public Function getProdInfoByProdIdAndStatus(prod_id As String, status As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT * FROM sf.b_prod_info WHERE factory_id=? and prod_id = ? and status = ? "
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", prod_id, status)
        If IsNothing(dt) Then
            getProdInfoByProdIdAndStatus = New DataTable
        Else
            getProdInfoByProdIdAndStatus = dt
        End If
    End Function

    Public Function setStatus(prodID As String, oper As String) As Integer
        Dim szSql As String = String.Empty
        Dim rtn As Integer
        szSql &= "update sf.b_prod_info set update_time = (SELECT CURRENT_TIMESTAMP(6)),"
        szSql &= " status = ?, tuo_mo_dt = (SELECT CURRENT_TIMESTAMP(6)), tuo_mo_ope = ?"
        szSql &= " where factory_id = ? and prod_id = ?"
        rtn = DBacs.ExecuteUpdateSql(szSql, -1, "7", oper, "TS", prodID)
        Return rtn
    End Function

End Class
